

"use strict";

define([
    "esri/Graphic",
    "sc/config/geometrySymbol"
],function (Graphic,geometrySymbol){

    var _map;
    var _mapView;
    
    var init = function (map,mapView) {
        _map = map;
        _mapView = mapView;
    };

    var go = function (geometry) {
        _mapView.goTo(geometry);
    };

    var dragPoint = function (point) {
        var pointGraphic = new Graphic({
            geometry : {
                type : "point",
                longitude: point[0],
                latitude: point[1]
            },
            symbol: geometrySymbol.getPointSymbol()
        });
        _mapView.graphics.add(pointGraphic);
        go(pointGraphic);
        return pointGraphic;
    };

   var reDragPoint = function (oldPoint,newPoint) {
       _mapView.graphics.remove(oldPoint);
       dragPoint(newPoint);
   };

     var dragLine = function (path) {
         var lineGraphic = new Graphic({
             geometry : {
                 type : "polyline",
                 path : line
             },
             symbol: geometrySymbol.getLineSymbol()
         });
         _mapView.graphics.add(lineGraphic);
         go(lineGraphic);
     };

    return {
        init : function (map,mapView) {
            init(map,mapView);
            return {
                dragPoint : dragPoint,
                dragLine : dragLine,
                reDragPoint : reDragPoint
            }
        }
    }
    
    
});